package com.uenpay.im.ui.old.activity.publicnumber;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

/**
 * @author SL
 * @created 2016-1-8 下午2:38:33
 * @copyRight http://www.qiyunxin.com
 * @function 序列化公众号
 */
public class DesPublicNumEntity {

	public static PublicNumEntity desPublicNumEntity(JSONObject json) {
		PublicNumEntity numEntity = new PublicNumEntity();
		numEntity.publicnoid = json.optString("publicnoid");
		numEntity.custid = json.optString("custid");
		numEntity.publicNumName = json.optString("nickname");
		numEntity.fundesc = json.optString("fundesc");
		numEntity.accmbody = json.optString("accmbody");
		if (json.has("isfollow")) {
			numEntity.isfollow = json.optInt("isfollow");
		}
		if (json.has("msgsetting")) {
			JSONObject jsonObject = json.optJSONObject("msgsetting");
			if (jsonObject.has("push")) {
				numEntity.push = jsonObject.optInt("push");
			}
		}
		return numEntity;
	}

	public static ArrayList<PublicNumEntity> desEntities(JSONArray jsonArray) {
		ArrayList<PublicNumEntity> arrayList = new ArrayList<PublicNumEntity>();
		if (jsonArray != null) {
			for (int i = 0, size = jsonArray.length(); i < size; i++) {
				arrayList.add(desPublicNumEntity(jsonArray.optJSONObject(i)));
			}
		}
		return arrayList;
	}
}
